'use strict'

const Service = require('egg').Service

class WallService extends Service {
  getList() {
    const { app } = this
    return app.model.Wall.findAll({
      include: [
        {
          model: app.model.Label,
          as: 'labels'
        },
        {
          model: app.model.Color,
          as: 'colors'
        }
      ]
    })
  }
  // 修改墙的标语
  async updateSlogan(id, slogan) {
    const { ctx, app } = this
    const result = await app.model.Wall.findOne({ where: { id } })
    if (!result) ctx.throw(400, '该记录不存在')
    return result.update({ slogan })
  }
}

module.exports = WallService
